/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package control

import dao.TestsDAO
import entity.Test
import java.sql.Connection
/**
 *
 * @author Tato
 */
class ControlTest {
    
    TestsDAO dao = new TestsDAO()
   
    def addTest(Test test){
       
        key = dao.create(test,DBConnection.establishConection())
        if(key > 0){
            test.id= key
            "Agregado"
        }
        else{
            "No agregado"
        }
    }
    
    def deleteTest(Test test){
        
        delete = dao.remove(test,DBConnection.establishConection())
        
        if(delete == true){
            "Borrado exitoso"
        }
        else{
            "Borrado falló"
        }     
    }
    
    def updateTest(Test test){
        if(dao.update(request,DBConnection.establishConection()) > 0){
               "Información actualizada"
            }
            
            else {
                "Información no actualizada"
            }
        
    }
    
     def findTest(Integer id){
         if(dao.find(id,DBConnection.establishConection())!= null  ){
               "Información actualizada"
            }
            
            else {
                "Información no actualizada"
            }
        
    }
	
}

